<?php  
class RecycleController extends AuthController{
	private $db;
	public function __init(){
		//商品模型
		$this->db=K('Goods');
	}
	/**
	 * 显示回收站列表
	 * @return [type] [description]
	 */
	public function index(){
		$goods=M()->join("__goods__ g LEFT JOIN __category__ c ON g.category_cid=c.cid")->where("recycle=1")->all();
		$this->assign('goods',$goods);
		$this->display();
	}
	/**
	 * 商品还原
	 * @return [type] [description]
	 */
	public function recover(){
		//商品主键
		$gid=Q('gid',0,'intval');
		// 组合更新的数据i
		$data=array('gid'=>$gid,'recycle'=>'0');
		if ($this->db->save($data)) {
			$this->success('还原成功','index');
		}else{
			$this->error('还原失败');
		}
	}
	public function del(){
		if ($this->db->delGoods()) {
			$this->success("删除成功");
		}else{
			$this->error("删除失败");
		}
	}
}
?>